package com.行为型模型.Q状态模式;

/**
 * 环境角色
 */
public class Context {
    //定义出所有的电梯状态
    public final static OpenningState openingState=new OpenningState();//开门状态，这时候电梯只能关闭
    public final static StoppingState stoppingState=new StoppingState();
    public final static ClosingState closingState=new ClosingState();
    public final static RunningState runningState=new RunningState();




    //定义一个当前电梯状态
    private AbstractLiftState liftState;

    public AbstractLiftState getLiftState() {
        return liftState;
    }

    public void setLiftState(AbstractLiftState lifeState) {
        //当前环境变量
        this.liftState = lifeState;
        //把当前的环境通知到各个实现类中
        this.liftState.setContext(this);
    }

    public void open(){
        this.liftState.open();
    }

    public void close(){
        this.liftState.close();
    }

    public void run(){
        this.liftState.run();
    }

    public void stop(){
        this.liftState.stop();
    }




}
